<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <script>
                function title() {
                    document.getElementById('atendimento').className='selected';
                }
                window.onload=title;
            </script>
            <h:form id="diaryForm" enctype="multipart/form-data">
                <h1 class="title">
                    <a href="#" class="back" onclick="history.go(-1)"/>
                    Agenda
                </h1>
                <p:messages autoUpdate="true" id="messages" closable="true"/>
                <div class="row">
                    <div class="twelve columns">
                        <div class="container_24 clearfix ">

                            <p:button icon="ui-icon-plusthick" value="Agendar"
                                      style="float:right;"
                                      outcome="atendimentopaciente.xhtml?step=1"
                                      styleClass="grid_3 ui-priority-primary"/>

                            <p:outputLabel value="Procedimento:" styleClass="grid_3" rendered="#{managerAgenda.procedureSelect ne null}"/>
                            <p:autoComplete value="#{managerAgenda.procedureSelect}" rendered="#{managerAgenda.procedureSelect ne null}"
                                            id="selectProcedure" panelStyle="max-height: 200px;" 
                                            completeMethod="#{managerProcedure.autocomplete}"  
                                            var="p" itemLabel="#{p.name}" itemValue="#{p}" forceSelection="true"
                                            styleClass="grid_5" dropdown="true" 
                                            converter="#{autocompleteconverter}" >  
                                <p:ajax event="itemSelect" update="@form" process="@form" listener="#{managerAgenda.selectProcedure()}"/>
                            </p:autoComplete>
                            <p:outputLabel value="Médico:" styleClass="grid_3" rendered="#{managerAgenda.doctorSelect ne null}"/>
                            <p:autoComplete value="#{managerAgenda.doctorSelect}"  rendered="#{managerAgenda.doctorSelect ne null}"
                                            id="selectDoctor" completeMethod="#{managerDoctor.autocomplete}"  
                                            var="d" itemLabel="#{d.name}" itemValue="#{d}" forceSelection="true"
                                            styleClass="grid_5" dropdown="true" panelStyle="max-height:200px;" 
                                            converter="#{autocompleteconverter}" >  
                                <p:ajax event="itemSelect" update="@form" process="@form" listener="#{managerAgenda.selectDoctor()}"/>
                            </p:autoComplete>

                            <p:tabView id="tabView" dynamic="true"
                                       widgetVar="tabviewv" styleClass="grid_24">


                                <p:tab id="tba0" title="Hoje">

                                    <p:panel styleClass="grid_16" 
                                             style="background: none; border: none; ">
                                        <h5>Agendamentos de Hoje</h5>
                                        <p:poll onstart="myscheduleDay.update();" interval="15" />
                                        <p:schedule  id="scheduleday" locale="pt" slotMinutes="15"
                                                     timeZone="GMT-3"
                                                     view="basicDay"  maxTime="21" minTime="6" 
                                                     showHeader="false"
                                                     value="#{managerAgenda.eventModelHoje}" widgetVar="myscheduleDay"> 


                                            <p:ajax event="eventSelect" listener="#{managerAgenda.onEventSelect}" 
                                                    update=":formDialog:eventDetails"
                                                    oncomplete="eventDialog.show();" />  


                                        </p:schedule>  
                                        <p:dataTable id="diarydehoje" rendered="false" var="sd" rowIndexVar="ddt"
                                                     paginator="true" rows="10" paginatorPosition="bottom"
                                                     value="#{managerAgenda.diarysSearch}"  >

                                            <f:facet name="header">
                                                Agendamentos de Hoje (#{managerAgenda.diarysSearch.size()})
                                            </f:facet>

                                            <p:column headerText="Ação" width="35">
                                                <p:commandButton icon="ui-icon-search"  title="Visualizar Evento" alt="Visualizar Evento"
                                                                 actionListener="#{managerAgenda.onEventSelectBasic(ddt)}"
                                                                 onclick="eventDialog.show();"
                                                                 process="@this" update=":formDialog:eventDetails"
                                                                 style="width: 25px; position: relative"/>
                                            </p:column>
                                            <p:column headerText="Horário" style="white-space: pre-wrap;" width="75">  
                                                <h:outputText value="#{sd.startTime}" >  
                                                    <f:convertDateTime pattern="HH:mm:ss "  locale="pt"/>
                                                </h:outputText>
                                            </p:column>  

                                            <p:column headerText="Paciente" style="white-space: pre-wrap;" width="120">  
                                                <h:outputText value="#{sd.customer.name}" />  
                                            </p:column>

                                            <p:column headerText="Médico">  
                                                <h:outputText value="#{sd.doctor.name}" />  
                                            </p:column>

                                            <p:column headerText="Procedimento">  
                                                <h:outputText value="#{sd.procedure.name}" />  
                                            </p:column>

                                        </p:dataTable>

                                    </p:panel>
                                    <p:panel id="filadeespera"
                                             header="Fila de Espera" styleClass="grid_7" style="text-align: center;">

                                        <p:button id="initialtreatment"  rendered="#{managerLayout.doctorByLogin}"
                                                  disabled="#{managerAgenda.selectedWaitingLine.id eq null}" icon="ui-icon-clock"
                                                  value="Iniciar Atendimento" outcome="atendimentoprocedimento.xhtml"
                                                  styleClass="grid_23 ui-priority-primary right">

                                            <f:param name="step" value="3"  />
                                            <f:param name="diary" value="#{managerAgenda.selectedWaitingLine.diary.id}" />
                                            <f:param name="atendimento" value="true" />
                                        </p:button>


                                        <div class="clear"></div>
                                        <p:dataTable id="waitingList"  var="cus" rowIndexVar="cusindex"
                                                     emptyMessage="Não há pacientes" style="width: 100%;" 
                                                     rowKey="#{cus.id}" paginator="true" rows="10" paginatorPosition="bottom"
                                                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink}"  
                                                     selection="#{managerAgenda.selectedWaitingLine}" selectionMode="single"
                                                     value="#{managerAgenda.waitingLines}">  

                                            <p:ajax event="rowSelect" update="@this, :diaryForm:tabView:filadeespera" />  

                                            <p:column width="40">
                                                <p:graphicImage  width="40" alt="#{cus.diary.customer.annex.id}" title="#{cus.diary.customer.annex.id}"
                                                                 url="#{cus.diary.customer.annex.id eq null ? '':'show/?annex='}#{cus.diary.customer.annex.id eq null ? 'assets/images/avatar.jpg':cus.diary.customer.annex.id}" />

                                            </p:column>
                                            <p:column width="100" style="text-align: left;">  
                                                <h:outputText value="#{cus.diary.customer.name}" style="white-space: pre-wrap; "/>  
                                            </p:column>  
                                        </p:dataTable>


                                    </p:panel>
                                </p:tab>
                                <p:tab id="tba1" title="Calendário">
                                    <p:panel id="customerplain" style="background: none; border: none; width: 100%;" >

                                        <div class="grid_20">
                                            <p:poll onstart="myschedule.update();" interval="15" />
                                            <p:schedule  id="schedule" locale="pt" slotMinutes="15" 
                                                         timeZone="GMT-3"
                                                         view="agendaDay"  maxTime="21" minTime="6" 
                                                         value="#{managerAgenda.eventModel}" widgetVar="myschedule">  

                                                <p:ajax event="dateSelect" listener="#{managerAgenda.onDateSelect}" 
                                                        update=":formDialog:newEventDetails" 
                                                        oncomplete="newEventDialog.show();" />  

                                                <p:ajax event="eventSelect" listener="#{managerAgenda.onEventSelect}" 
                                                        update=":formDialog:eventDetails"
                                                        oncomplete="eventDialog.show();" />  

                                                <p:ajax event="eventResize" listener="#{managerAgenda.onEventResize}"  />  

                                            </p:schedule>  
                                        </div>

                                    </p:panel>
                                </p:tab>

                                <p:tab id="tba3" title="Pesquisar">
                                    <p:panel id="searchDiaryPanel"  style="background: none; border: none; width: 100%;" >
                                        <p:outputLabel for="nameCustomer" value="Nome:" styleClass="grid_3"/>
                                        <p:inputText id="nameCustomer" styleClass="grid_20" accesskey="70"
                                                     value="#{managerAgenda.customerSearchDiary.name}"/>

                                        <div class="buttonAction">
                                            <p:commandButton value="Pesquisar" icon="ui-icon-search"
                                                             update="searchDiaryPanel" process="searchDiaryPanel"
                                                             actionListener="#{managerAgenda.findDiaryCustomer()}"
                                                             styleClass="ui-priority-primary" />
                                        </div >

                                        <p:dataTable id="searchDiary" var="sd" rowIndexVar="ddt"
                                                     paginator="true" rows="8" paginatorPosition="bottom"
                                                     value="#{managerAgenda.diarysSearch}"  >

                                            <f:facet name="header">
                                                Resultados (#{managerAgenda.diarysSearch.size()})
                                            </f:facet>

                                            <p:column headerText="Ação" width="35">
                                                <p:button icon="ui-icon-search" outcome="atendimentoprocedimento.xhtml"
                                                          title="Visualizar Evento" alt="Visualizar Evento"
                                                          style="width: 25px; position: relative">
                                                    <f:param name="step" value="3"  />
                                                    <f:param name="diary" value="#{sd.id}" />
                                                    <f:param name="atendimento" value="true" 
                                                             rendered="#{managerLayout.doctorByLogin and sd.diarySituation ne null and
                                                                                         sd.diarySituation.toString() eq 'Aguardando Atendimento'}" />
                                                </p:button>
                                            </p:column>
                                            <p:column headerText="Data" style="white-space: pre-wrap;" width="75">  
                                                <h:outputText value="#{sd.startTime}" >  
                                                    <f:convertDateTime pattern="dd/MM/yyy HH:mm:ss "  locale="pt"/>
                                                </h:outputText>
                                            </p:column>  

                                            <p:column headerText="Situação" style="white-space: pre-wrap;" width="150">  
                                                <h:outputText value="#{sd.diarySituation.toString()}" />  
                                            </p:column>
                                            <p:column headerText="Paciente" style="white-space: pre-wrap;" >  
                                                <h:outputText value="#{sd.customer.name}" />  
                                            </p:column>

                                            <p:column headerText="Médico" width="120">  
                                                <h:outputText value="#{sd.doctor.name}" />  
                                            </p:column>

                                            <p:column headerText="Procedimento" width="120">  
                                                <h:outputText value="#{sd.procedure.name}" />  
                                            </p:column>

                                        </p:dataTable>
                                    </p:panel>
                                </p:tab>

                            </p:tabView>
                            <div class="grid_23">
                                <h5>Legenda</h5>
                                <div class="agendado grid_1"
                                     style="height: 25px; width: 3%">
                                </div>
                                <div class="grid_2">
                                    Agendado
                                </div>
                                <div class="confirmado fc-event-skin grid_1"
                                     style="height: 25px;  width: 3%">
                                </div>
                                <div class="grid_3" style=" width: 7%">
                                    Confirmado
                                </div>
                                <div class="cancelado fc-event-skin grid_1"
                                     style="height: 25px;  width: 3%">
                                </div>
                                <div class="grid_2">
                                    Cancelado
                                </div>
                                <div class="aguardando_atendimento fc-event-skin grid_1"
                                     style="height: 25px;  width: 3%">
                                </div>
                                <div class="grid_5">
                                    Aguardando Atendimento
                                </div>
                                <div class="atendimento_realizado fc-event-skin grid_1"
                                     style="height: 25px;  width: 3%">
                                </div>
                                <div class="grid_6">
                                    Atendimento Realizado
                                </div>
                                <div class="clear"/>
                            </div>
                            <p:dialog  widgetVar="dialogmsg" header="Alerta" modal="true"
                                       width="800" showEffect="clip" resizable="false" >
                                <p:messages autoUpdate="true"/>
                                <h2>#{managerAgenda.msg}</h2> 
                            </p:dialog>
                            <p:dialog  widgetVar="fImprimir" header="Imprimir Folha de Rosto" modal="true"
                                       width="800" showEffect="clip" resizable="false" >

                                <p:ajax event="close" listener="#{managerAgenda.cleanPrint()}" update="fPanelImprimir" /> 

                                <p:panel id="fPanelImprimir" style="background: none; border: none;" styleClass="container_24 clearfix " >
                                    <p:dataTable id="diarysPrint" var="print" paginator="true" rows="10"
                                                 paginatorPosition="bottom"
                                                 value="#{managerAgenda.diarysDisp}"
                                                 rowKey="#{print.id}" selection="#{managerAgenda.diarysSelected}" 
                                                 selectionMode="multiple">

                                        <p:ajax event="rowSelect"  process="@this" update="@this"/>
                                        <p:ajax event="rowUnselect"  process="@this" update="@this"/>

                                        <p:column headerText="Data">  
                                            <h:outputText value="#{print.startTime}" >  
                                                <f:convertDateTime pattern="dd/MM/yyyy à's' HH:mm:ss"/>
                                            </h:outputText>
                                        </p:column>  

                                        <p:column headerText="Situação" style="white-space: pre-wrap;" >  
                                            <h:outputText value="#{print.diarySituation.toString()}" />  
                                        </p:column>  

                                        <p:column headerText="Procedimento" style="white-space: pre-wrap;">  
                                            <h:outputText value="#{print.retorno ? 'Retorno - ':''}#{print.procedure.name}" />  
                                        </p:column>  

                                        <p:column headerText="Paciente" style="white-space: pre-wrap;">  
                                            <h:outputText value="#{print.customer.name}" />  
                                        </p:column>


                                    </p:dataTable>


                                </p:panel>
                                <f:facet name="footer" >
                                    <div class="grid_24 right">
                                        <p:commandButton 
                                            value="Imprimir" icon="ui-icon-print" immediate="true"
                                            ajax="false"  onclick="this.form.target='_blank'"
                                            styleClass="right" action="#{managerAgenda.diaryReport()}"/>
                                    </div>
                                </f:facet>
                            </p:dialog>
                            <p:dialog  widgetVar="fDialog" header="Forma de Pagamento" modal="true"
                                       width="800" dynamic="true"  resizable="false" > 

                                <p:ajax event="close"  update="@this, :diaryForm:fPanel" /> 

                                <p:panel id="fPanel" style="background: none; border: none;" styleClass="container_24 clearfix " >

                                    <p:messages id="msgincome" autoUpdate="true" />


                                    <p:outputLabel value="" />
                                    <p:outputLabel for="procedureBasic" value="Procedimento" styleClass="grid_5"/>  
                                    <p:inputText value="#{managerAgenda.procedure.name}" 
                                                 id="procedureBasic" readonly="true"  styleClass="grid_17"
                                                 style="margin-right:0px;"/>

                                    <p:outputLabel for="doctorBasic" value="Médico" styleClass="grid_5"/>  
                                    <p:inputText value="#{managerAgenda.doctor.name}" 
                                                 id="doctorBasic" readonly="true"  styleClass="grid_17" style="margin-right:0px;"/>

                                    <p:outputLabel value="Forma de Pagamento" styleClass="grid_5"/> 
                                    <div class="grid_16">
                                        <p:selectOneMenu style="width: 108%;" panelStyle="width:150px;" 
                                                         value="#{managerAgenda.income.paymentType}" >   
                                            <f:selectItems value="#{managerAgenda.selectPaymentType()}" />
                                            <p:ajax update=":diaryForm:labelAmountMoney, :diaryForm:amountcard, :diaryForm:amountmoney, :diaryForm:labelAmountCard" />
                                        </p:selectOneMenu>
                                    </div>

                                    <p:outputLabel for="famount" value="Valor" styleClass="grid_5"/> 

                                    <p:inputText id="famount" styleClass="grid_17" 
                                                 value="#{managerAgenda.income.amount}"
                                                 onkeypress="jQuery(this).autoNumeric({aSign:'R$ ', aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                        <p:ajax event="blur" update="@this, ftotalamount, famountpaid" 
                                                listener="#{managerAgenda.calcDiscount()}"/>
                                    </p:inputText>

                                    <p:watermark value="R$" for="fdiscount"  />
                                    <p:watermark value="%" for="fdiscountpercent" />

                                    <p:outputLabel for="fdiscount" value="Desconto" styleClass="grid_5"/>  
                                    <p:inputText id="fdiscount" styleClass="grid_8" 
                                                 value="#{managerAgenda.income.discount}"
                                                 onkeypress="jQuery(this).autoNumeric({aSign:'R$ ',aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                        <p:ajax event="blur" update="@this, ftotalamount, famountpaid" 
                                                listener="#{managerAgenda.calcDiscount()}"/>
                                    </p:inputText>

                                    <p:inputText styleClass="grid_9" 
                                                 id="fdiscountpercent"
                                                 style="width: 34.1%"
                                                 onkeypress="jQuery(this).autoNumeric({pSign: 's',aSign: '%', aSep: '.', aDec: ','} );"
                                                 value="#{managerAgenda.discount}"  >
                                        <f:convertNumber type="percent"  locale="pt,BR"  />
                                        <p:ajax event="blur" update="@this, ftotalamount, famountpaid, fdiscount" 
                                                listener="#{managerAgenda.calcDiscountPorce()}"/>
                                    </p:inputText>

                                    <div class="clear"/>

                                    <p:watermark value="Dinheiro" for="amountmoney"  />
                                    <p:watermark value="Cartão" for="amountcard" />

                                    <p:outputLabel id="labelAmountMoney"  for="amountmoney" 
                                                   value="Valor Dinheiro:" styleClass="grid_5" style="display: #{managerAgenda.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}"/>  
                                    <p:inputText  style="display: #{managerAgenda.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}" 
                                                  id="amountmoney" styleClass="grid_6" 
                                                  value="#{managerAgenda.income.amountMoney}"
                                                  onkeypress="jQuery(this).autoNumeric({aSign:'R$ ',aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </p:inputText>

                                    <p:outputLabel id="labelAmountCard"  for="amountcard" 
                                                   value="Valor Cartão:" styleClass="grid_4" style="display: #{managerAgenda.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}"/>  


                                    <p:inputText  style="display: #{managerAgenda.income.paymentType eq 'MONEY_CARD' ? 'block':'none'}; width: 26%;" 
                                                  id="amountcard" styleClass="grid_6" 
                                                  value="#{managerAgenda.income.amountCard}"
                                                  onkeypress="jQuery(this).autoNumeric({aSign:'R$ ',aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </p:inputText>

                                    <div class="clear"/>

                                    <p:outputLabel for="ftotalamount" value="Valor Total" styleClass="grid_5"/>  
                                    <p:inputText id="ftotalamount" styleClass="grid_17"  readonly="true" disabled="true"
                                                 value="#{managerAgenda.income.totalAmount}"
                                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                                        <f:convertNumber pattern="#,###,##0.00"/>
                                    </p:inputText>

                                    <p:outputLabel for="famountpaid" value="Valor Pago" styleClass="grid_5"/>  
                                    <p:inputText id="famountpaid" styleClass="grid_8" 
                                                 value="#{managerAgenda.income.amountPaid}"
                                                 onkeypress="jQuery(this).autoNumeric({aSign:'R$ ', aSep: '.', aDec: ','} );">
                                        <f:convertNumber type="currency" locale="pt,BR"/>
                                    </p:inputText>


                                    <p:outputLabel for="dateincome" value="Em:" styleClass="grid_2" style="width: 5%;"/>  
                                    <p:calendar id="dateincome" value="#{managerAgenda.income.createAt}" 
                                                showOn="button" styleClass="grid_7" pattern="dd/MM/yyyy HH:mm"/>  


                                    <div class="clear"/>
                                    <h:outputLabel rendered="#{managerAgenda.income.systemUser ne null}" value="Recebido por: #{managerAgenda.income.systemUser.name}" 
                                                   styleClass="grid_15" style="text-align: right;"/>
                                    <h:outputLabel rendered="#{managerAgenda.income.systemUser ne null}" value="em: " styleClass="grid_1" style="text-align: right;"/>
                                    <h:outputLabel rendered="#{managerAgenda.income.systemUser ne null}" value="#{managerAgenda.income.createAt}" styleClass="grid_5">
                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                    </h:outputLabel>



                                    <div class="clear"/>

                                    <div class="buttonAction">
                                        <p:commandButton icon="ui-icon-close" process="@this, fPanel" update="@this, fPanel"
                                                         value="Cancelar" disabled="#{managerAgenda.income.id eq null}"
                                                         actionListener="#{managerAgenda.clearIncome()}"
                                                         oncomplete="fDialog.hide();"/>

                                        <p:commandButton icon="ui-icon-check" process="@this, fPanel" update="@this, fPanel"
                                                         value="Confirmar" actionListener="#{managerAgenda.saveIncome()}"
                                                         styleClass="ui-priority-primary"/>
                                    </div>
                                </p:panel>
                            </p:dialog>

                        </div>
                    </div>
                </div>
            </h:form>

            <h:form id="formDialog">

                <p:dialog id="eventNew"  widgetVar="newEventDialog" header="Agenda" modal="true"
                          resizable="false" dynamic="true" 
                          width="350"  height="220"  > 

                    <p:panel id="newEventDetails" style="background: none; border: none; " 
                             styleClass="container_24 clearfix" >

                        <p:button outcome="atendimentopaciente.xhtml" 
                                  value="Novo Atendimento" icon="ui-icon-plusthick" 
                                  styleClass="ui-priority-primary grid_24" style="margin-top: 50px;">
                            <f:param name="step" value="1" />
                            <f:param name="date" value="#{managerAgenda.dataNovoAtendimento}" />
                        </p:button>
                    </p:panel>

                </p:dialog>
                <p:dialog id="eventD"  widgetVar="eventDialog" header="Agenda" modal="true"
                          resizable="false" dynamic="true" 
                          width="900"  height="420"  > 

                    <p:ajax event="close" listener="#{managerAgenda.clean()}" 
                            update="eventD" /> 


                    <p:panel id="eventDetails" style="background: none; border: none;" 
                             styleClass="container_24 clearfix " >

                        <fieldset style="margin: 0px;">
                            <legend> 
                                <h5 style="font-size: 1.4em;">
                                    <h:outputText  value="#{managerAgenda.customer.gender eq 'MASCULINO' ?
                                                            'Sr. ':'Sra. '}#{managerAgenda.customer.name}"/>
                                    <h:outputText  value="#{managerAgenda.age ne '0' ? ' - ' : ''}#{managerAgenda.age ne '0' ?
                                                            managerAgenda.age : ''}#{managerAgenda.age ne '0' ? ' Anos' : ''}"/>
                                </h5>
                            </legend>



                            <div class="clear"/>
                            <p:panel header="Paciente" styleClass="grid_6" style="text-align: center;">
                                <p:graphicImage id="avatar2" styleClass="image grid_4" 
                                                style="margin-left:1%; width: 150px;" 
                                                alt="#{managerAgenda.customer.annex.id}" 
                                                title="#{managerAgenda.customer.annex.id}"
                                                url="#{managerAgenda.customer.annex.id eq null ? '':'show/?annex='}
                                                #{managerAgenda.customer.annex.id eq null ? 'assets/images/avatar.jpg': managerAgenda.customer.annex.id}" />
                                <div class="clear"></div>

                                <div class="grid_24" style="text-align: left; ">

                                    <h:outputText  value="Idade:" styleClass="grid_13" style="font-weight: bold; "/>
                                    <h:outputText  value="#{managerAgenda.age ne '0' ? ' ' : ''}
                                                   #{managerAgenda.age ne '0' ?
                                                     managerAgenda.age : ''}
                                                   #{managerAgenda.age ne '0' ? ' Anos' : ''}"
                                                   styleClass="grid_9"/>

                                    <h:outputText value="Estado Civil:" styleClass="grid_15" style="font-weight: bold;"/>
                                    <h:outputText styleClass="grid_8" value="#{managerAgenda.customer.civilStatus.name}"/>
                                    <div class="clear"></div>
                                    <h:outputText value="Telefones:" styleClass="grid_13" style="font-weight: bold;"/>
                                    <div class="clear"></div>
                                    <h:outputText styleClass="grid_23 push_7" value="#{managerAgenda.customer.phone}"/>
                                    <div class="clear"></div>
                                    <h:outputText styleClass="grid_23 push_7" value="#{managerAgenda.customer.cellular}"/>
                                    <div class="clear"></div>
                                    <h:outputText value="E-mail:" styleClass="grid_13" style="font-weight: bold;"/>
                                    <h:outputText styleClass="grid_12" value="#{managerAgenda.customer.email}"/>
                                    <div class="clear"></div>

                                </div>
                            </p:panel>
                            <p:panel header="Atendimento"  styleClass="grid_17" >

                                <p:outputLabel for="operator" value="Convênio:" styleClass="grid_5"/>
                                <p:inputText value="#{managerAgenda.operator.name}" 
                                             id="operator" styleClass="grid_18" 
                                             disabled="true"
                                             style="margin-right:0px;"/>

                                <div class="clear"></div>
                                <p:outputLabel for="procedure" value="Procedimento:" styleClass="grid_5"/>  
                                <p:inputText value="#{managerAgenda.procedure.name}" 
                                             disabled="true"
                                             id="procedure" readonly="true"  styleClass="grid_18" style="margin-right:0px;"/>

                                <div class="clear"/>
                                <p:outputLabel for="doctor" value="Médico Resp.:" styleClass="grid_5"  />  
                                <p:inputText value="#{managerAgenda.doctor.name}" 
                                             disabled="true"
                                             id="doctor" readonly="true"  styleClass="grid_18" style="margin-right:0px;"/>


                                <div class="clear"/>
                                <p:outputLabel for="doctorRequest" value="Médico Solicitante:" styleClass="grid_6" 
                                               style="margin-left:-17px;"/>  
                                <p:inputText value="#{managerAgenda.doctorRequest.name}" 
                                             disabled="true"
                                             id="doctorRequest" readonly="true" 
                                             styleClass="grid_18"/>

                                <p:outputLabel for="from" value="De:" styleClass="grid_5"/>  
                                <p:calendar id="from" value="#{managerAgenda.diary.startTime}" 
                                            showOn="button" styleClass="grid_7" pattern="dd/MM/yyyy HH:mm"
                                            required="true" disabled="true">  
                                </p:calendar>

                                <p:outputLabel for="to" value="Até:" styleClass="grid_3"/>  
                                <p:calendar id="to" value="#{managerAgenda.diary.endTime}" 
                                            showOn="button" styleClass="grid_9" style="width: 29.767%;" pattern="HH:mm" 
                                            required="true" timeOnly="true" disabled="true"/>  
                                <div class="clear"></div>
                                <p:outputLabel for="obs" value="Observações:" styleClass="grid_5"/>  
                                <p:inputTextarea autoResize="false" id="obs" disabled="true" value="#{managerAgenda.diary.observation}" 
                                                 styleClass="grid_18"/> 
                                <p:outputLabel value="Situação:" styleClass="grid_5"/>  
                                <p:inputText value="#{managerAgenda.diary.diarySituation.toString()}" 
                                             disabled="true"
                                             styleClass="grid_18"/>

                            </p:panel>

                            <div style="width: 50%; background: none; border: none; margin: 0; margin-top: 0px;
                                 padding: 0; float: right;"  >
                                <p:button icon="ui-icon-search" outcome="atendimentoprocedimento.xhtml"
                                          value="Visualizar Atendimento" 
                                          title="Visualizar Evento" alt="Visualizar Evento"
                                          style="width: 220px"
                                          styleClass="ui-priority-primary">
                                    <f:param name="step" value="3"  />
                                    <f:param name="diary" value="#{managerAgenda.diary.id}" />
                                    <f:param name="atendimento" value="true" rendered="#{managerLayout.doctorByLogin and managerAgenda.diary.diarySituation ne null and
                                                                                         managerAgenda.diary.diarySituation.toString() eq 'Aguardando Atendimento'}" />
                                </p:button>
                                <p:commandButton id="relPrint" rendered="#{managerAgenda.diary.id != null}"
                                                 value="Imprimir" immediate="true" icon="ui-icon-print" 
                                                 update=":diaryForm:fPanelImprimir, :diaryForm:diarysPrint"
                                                 actionListener="#{managerAgenda.verifyOtherDiary()}"
                                                 oncomplete="fImprimir.show();" />
                            </div>

                        </fieldset>
                    </p:panel>
                </p:dialog>


            </h:form>

            <script type="text/javascript">
                PrimeFaces.locales['pt'] = {  
                    closeText: 'Fechar',  
                    prevText: 'Anterior',  
                    nextText: 'Próximo',  
                    currentText: 'Começo',  
                    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],  
                    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun', 'Jul','Ago','Set','Out','Nov','Dez'],  
                    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],  
                    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],  
                    dayNamesMin: ['D','S','T','Q','Q','S','S'],  
                    weekHeader: 'Semana',  
                    firstDay: 1,  
                    isRTL: false,  
                    showMonthAfterYear: false,  
                    yearSuffix: '',  
                    timeOnlyTitle: 'Só Horas',  
                    timeText: 'Tempo',  
                    hourText: 'Hora',  
                    minuteText: 'Minuto',  
                    secondText: 'Segundo',  
                    currentText: 'Data Atual',  
                    ampm: true,  
                    month: 'Mês',  
                    week: 'Semana',  
                    day: 'Dia',  
                    allDayText : 'Todo Dia'  
                };  
            </script>
        </ui:define>
    </ui:composition>

</html>
